<?php

class Default_Model_User extends Zend_Db_Table_Abstract
{

	protected $_name = 'user';

	public function insert(array $data)
	{
		if (empty($data['userpass']))
		{
			unset($data['userpass']);
		}
		else
		{
			$data['userpass'] = sha1($data['userpass']);
		}
		$data['created'] = new Zend_Db_Expr('NOW()');
		$data['hash'] = sha1(uniqid('', true));
		return parent::insert($data);
	}

	public function update(array $data, $where)
	{
		if (empty($data['userpass']))
		{
			unset($data['userpass']);
		}
		else
		{
			$data['userpass'] = sha1($data['userpass']);
		}
		return parent::update($data, $where);
	}

	public function select($withFromPart = self::SELECT_WITHOUT_FROM_PART)
	{
		$select = parent::select($withFromPart)
			->where('is_deleted = 0');
		return $select;
	}

}